#include <iostream>


#define N 10

using std::cout;
using std::endl;
//编写一个类，实现简单的栈。栈中有以下操作，并自行写出测试用例，每个函数都需要测试到。

class Stack 
{
public:

    Stack()
        : _stack(new int[N] ())
        , _size(0){
        cout << "Stack()" << endl;
    }
    ~Stack(){
        cout << "~Stack()" << endl;
        if(_stack){
            delete [] _stack;
            _stack = nullptr;
        }
    }

    bool empty(){
        return _size == 0 ? true : false;
    }
    bool full(){
        return _size == N ? true : false;
    }
    void push(const int& val){
        if(full()){
            cout << "栈满" << endl;
        }else{
            _stack[_size++] = val;
        }
    }
    int pop(){
        if(empty()){
            cout << "栈空" << endl;
            return (1 << 32) - 1;
        }else{
            return _stack[--_size];
        }
    }
    int top(){
        if(empty()){
            cout << "栈空" << endl;
            return (1 << 32) - 1;
        }else{
            return _stack[_size - 1];
        }
    }
    Stack(const Stack& rhs) = delete;
    Stack& operator=(const Stack& rhs) = delete;

private:
    int* _stack;
    size_t _size; 
};

int main(void){
    
    Stack stack;
    for(int i = 10; i > 0; --i){
        stack.push(i);
        cout << stack.top() << endl;
    }
        
    stack.push(11);
    for(int i = 0; i < N; ++i)
        cout << stack.pop() << endl;

    stack.pop();
    return 0;
}